home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 3
/
Cream of the Crop 3.iso
/
comm
/
te2_130t.zip
/
TE2INST.003
/
UserMenu.scr
< prev
next >
Wrap
Text File
|
1994-03-28
|
6KB
|
171 lines
;; -------------------------------------------------------------------------
;;
;; UserMenu.Scr -- Copyright (c) 1992-94, Oberon Software, Mankato Mn
;; Author: Brady Flowers, 07/09/92
;; Updated: 3/16/94
;;
;; Note: Updated 3/16/94 to use the new, TE/2 1.30 PopupMenu() API
;; and still maintain backwards compatibility with older scripts
;; which call UserMenu.
;;
;; Usage: This script allows the creation of a popup menu with up to
;; ten items. The user may use the up and down arrows and ENTER
;; key to select items or may press the letter or number corresponding
;; to the first character of an item (these must be unique for this
;; to work as expected). If the user presses ESCape the menu is
;; aborted.
;;
;; The calling script must define at least a subset of this file's
;; global variables identically to the way they are defined herein.
;; These variables are used for input and output parameters.
;;
;; The following variables should be set on entry:
;; usrmnuItems -- total number of menu items (1 .. 10)
;; usrmnuSelect -- initially selected item (1 .. usrmnuItems)
;; if this is invalid, 1 is assumed
;; usrmnuTop -- top row of menu dialog
;; usrmnuLeft -- left column of menu dialog
;; note: dialog dimensions are calculated
;; automatically
;; usrmnuAttr -- 'normal' color attribute (defaults to
;; the standard TE/2 dialog normal attribute if
;; not specified
;; usrmnuHiAttr -- 'selected' color attribute (defaults to
;; the standard TE/2 dialog highligh attribute if
;; not specified
;; usrmnuTitle -- title string for the menu -- automatically
;; centered on the top row of the menu dialog
;; usrmnuItem1 thru
;; usrmnuItem10 -- fill in as many of these as you specified
;; in usrmnuItems, extra ones are ignored
;; the first character of each item should
;; be unique if you want mnemonic matching to
;; work well.
;;
;; The return code of this script is in usrmnuSelect. If the
;; user made a selection, the value of usrmnuSelect on exit will
;; be the item selected. If the user pressed ESCape to exit the
;; menu, the value will be zero.
;;
;;
;; Example:
;;
;; ;; MenuTest.scr
;; global integer usrmnuItems = 4
;; global integer usrmnuSelect = 1
;; global string usrmnuTitle = "Please Select One"
;; global string usrmnuItem1 = "Apples "
;; global string usrmnuItem2 = "Bananas "
;; global string usrmnuItem3 = "Coconuts "
;; global string usrmnuItem4 = "Dates "
;; global integer usrmnuTop = 10
;; global integer usrmnuLeft = 20
;; global integer usrmnuAttr = 0x1f
;; global integer usrmnuHiAttr = 0x71
;;
;; program
;; run("UserMenu")
;; if usrmnuSelect == 0
;; message("^M^JMenu choice aborted^M^J")
;; else
;; message("^M^JYou selected item %d^M^J", usrmnuSelect)
;; endif
;; end
;;
;;
;; -------------------------------------------------------------------------
;; -------------------------------------------------------------------------
;; GLOBAL variable
global integer usrmnuSelect
global integer usrmnuTop
global integer usrmnuLeft
global integer usrmnuAttr
global integer usrmnuHiAttr
global integer usrmnuItems
global string usrmnuTitle
global string usrmnuItem1
global string usrmnuItem2
global string usrmnuItem3
global string usrmnuItem4
global string usrmnuItem5
global string usrmnuItem6
global string usrmnuItem7
global string usrmnuItem8
global string usrmnuItem9
global string usrmnuItem10
;; -------------------------------------------------------------------------
;; LOCAL Variables
string mnuItems
;; -------------------------------------------------------------------------
subroutine SetupItems
mnuItems = ""
if usrmnuItems > 0
mnuItems = mnuItems + "ß" + usrmnuItem1
endif
if usrmnuItems > 1
mnuItems = mnuItems + "ß" + usrmnuItem2
endif
if usrmnuItems > 2
mnuItems = mnuItems + "ß" + usrmnuItem3
endif
if usrmnuItems > 3
mnuItems = mnuItems + "ß" + usrmnuItem4
endif
if usrmnuItems > 4
mnuItems = mnuItems + "ß" + usrmnuItem5
endif
if usrmnuItems > 5
mnuItems = mnuItems + "ß" + usrmnuItem6
endif
if usrmnuItems > 6
mnuItems = mnuItems + "ß" + usrmnuItem7
endif
if usrmnuItems > 7
mnuItems = mnuItems + "ß" + usrmnuItem8
endif
if usrmnuItems > 8
mnuItems = mnuItems + "ß" + usrmnuItem9
endif
if usrmnuItems > 9
mnuItems = mnuItems + "ß" + usrmnuItem10
endif
mnuItems = mnuItems + "ß"
endsub
;; -----------------------------------------------------------------
;; Main driver for the menu
;; -----------------------------------------------------------------
subroutine UserMenu
;; Make sure defaults are set if they are needed
if usrmnuAttr == 0
usrmnuAttr = DLogNormAttr
endif
if usrmnuHiAttr == 0
usrmnuHiAttr = DLogHiAttr
endif
gosub SetupItems
usrmnuSelect = PopupMenu(usrmnuTitle, mnuItems, usrmnuTop, usrmnuLeft, usrmnuAttr, usrmnuHiAttr, usrmnuSelect)
endsub
program
if (usrmnuItems < 1) OR (usrmnuItems > 10)
errormsg("Invalid number of Menu Items for UserMenu", "Must be from 1 to 10 items")
usrmnuSelect = 0
else
gosub UserMenu
endif
end